import 'dart:io';

import 'package:dio/dio.dart' hide Headers;
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:retrofit/retrofit.dart';

import '../models/http_models.dart';
import '../utils/utils.dart';
import 'app_dio.dart';

part 'app_data_source.g.dart';

final appDataSourceProvider = Provider((ref) => AppDataSource(ref));

///http://106.38.204.135/ef-api/api/news?limit=1&page=1&type=0
///https://www.oklink.com/api/v5/explorer/tokenprice/price-multi?chainShortName=eth&tokenContractAddress=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
///https://www.oklink.com/api/v5/explorer/tokenprice/token-list?token=btc
///https://www.oklink.com/api/v5/explorer/tokenprice/price-multi?chainShortName=btc&tokenContractAddress=0x0000000000000000000000000000000000000000
///
///不写token 默认获取平台币的价格 如果传入token获取token的价格
/// https://www.oklink.com/api/v5/explorer/tokenprice/historical?chainId=56&tokenContractAddress=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&limit=1
///
///
/// https://www.oklink.com/api/v5/explorer/tokenprice/token-list?token=apt&limit=50
/// https://www.oklink.com/api/v5/explorer/tokenprice/price-multi?chainShortName=APT&tokenContractAddress=0x1::aptos_coin::AptosCoin
@RestApi()
abstract class AppDataSource {
  factory AppDataSource(Ref ref) => _AppDataSource(ref.read(dioProvider));

  ///多文件上传
  @POST('common/uploadFiles')
  @MultiPart()
  Future<ResponseBodyMt> postFormData3(
      @Part() List<File> file, @CancelRequest() cancelRequest);

  @GET(
      'https://lizhitong.zc.gov.cn/webservice/CreditsChangeService.asmx/GetUserCredits')
  Future<dynamic> priceS(
      @Queries() Map<String, dynamic> params, @CancelRequest() cancelRequest);

  @POST('https://lizhitong.zc.gov.cn/webservice/CreditsChangeService.asmx')
  @Headers({'Content-Type': 'text/xml; charset=utf-8'})
  Future<dynamic> testApi(
      @Body() Map<String, dynamic> requestJson, @CancelRequest() cancelRequest);

  @POST('auth')
  Future<dynamic> auth(
      @Body() Map<String, dynamic> requestJson, @CancelRequest() cancelRequest);

  @GET('product.product')
  Future<dynamic> product2(
      @Queries() Map<String, dynamic> params, @CancelRequest() cancelRequest);

  @GET('product.product/{id}')
  Future<dynamic> productDetail(@Path("id") String id, @CancelRequest() cancelRequest);
}
